package org.budo.weixin.work.api.entity;

import java.io.Serializable;

import org.budo.xml.XmlObject;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

/**
 * @author lmw
 */
@Getter
@Setter
@NoArgsConstructor
@ToString
public class WebhookSpRecordDetail implements SpRecordDetail, Serializable {
    private static final long serialVersionUID = 5276815379184978660L;

    private XmlObject xml;

    private Integer index;

    public WebhookSpRecordDetail(Integer index, XmlObject xml) {
        this.index = index;
        this.xml = xml;
    }

    public String getSpStatus() {
        return this.getXml().getChildNodeTextContentByName("SpStatus");
    }

    public String getApproverUserId() {
        XmlObject approver = this.getXml().getChildNodeByName("Approver");
        return approver.getChildNodeTextContentByName("UserId");
    }

    public String getSpeech() {
        return this.getXml().getChildNodeTextContentByName("Speech");
    }

    public Integer getSpRecordIndex() {
        return this.index;
    }
}